-- @owner: xuwenfei1
-- @date: 2025/3/21
-- @testpoint: RAISE_APPLICATION_ERROR参数为null/空/空格测试，部分功能合理报错

@conn PrimaryDbAmode;
--step0：前置条件;expect: 成功
drop PROCEDURE if exists proc1_04;
drop PROCEDURE if exists proc2_04;
drop PROCEDURE if exists proc3_04;
drop PROCEDURE if exists proc4_04;
drop PROCEDURE if exists proc5_04;
drop PROCEDURE if exists proc6_04;
drop PROCEDURE if exists proc7_04;
drop PROCEDURE if exists proc8_04;
drop PROCEDURE if exists proc9_04;

--step1: 创建存储过程;expect: 创建存储过程成功，message为null/空报错;为空格报指定错
CREATE or replace PROCEDURE proc1_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(-20001+1, '');
    END IF;
END;
/
BEGIN
    proc1_04(TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc2_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
    RAISE_APPLICATION_ERROR(-20001+1, null);
    END IF;
END;
/
BEGIN
    proc2_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc3_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
    RAISE_APPLICATION_ERROR(-20001+1, ' ');
    END IF;
END;
/
BEGIN
    proc3_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/

--step2: 创建存储过程;expect:创建存储过程成功，code为null/空/空格报错
CREATE or replace PROCEDURE proc4_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
    RAISE_APPLICATION_ERROR('', 'null');
    END IF;
END;
/
BEGIN
    proc4_04(TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc5_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(null, 'null');
    END IF;
END;
/
BEGIN
    proc5_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc6_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(' ', '+');
    END IF;
END;
/
BEGIN
    proc6_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/

--step3: 创建存储过程;expect: 创建存储过程成功，keep_errors为null/空报指定错;为空格报错
CREATE or replace PROCEDURE proc7_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(-20988, 'null','');
    END IF;
END;
/
BEGIN
    proc7_04(TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc8_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(-20988, 'null',null);
    END IF;
END;
/
BEGIN
    proc8_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/
CREATE or replace PROCEDURE proc9_04 (
 due_date DATE,
 today DATE
) AUTHID DEFINER
IS
BEGIN
    IF due_date < today THEN
        RAISE_APPLICATION_ERROR(-20988, 'null',' ');
    END IF;
END;
/
BEGIN
    proc9_04 (TO_DATE('01-JUL-2010', 'DD-MON-YYYY'),TO_DATE('09-JUL-2010', 'DD-MON-YYYY'));
end;
/

--step4: 清理环境;expect: 成功
drop PROCEDURE if exists proc1_04;
drop PROCEDURE if exists proc2_04;
drop PROCEDURE if exists proc3_04;
drop PROCEDURE if exists proc4_04;
drop PROCEDURE if exists proc5_04;
drop PROCEDURE if exists proc6_04;
drop PROCEDURE if exists proc7_04;
drop PROCEDURE if exists proc8_04;
drop PROCEDURE if exists proc9_04;
